package com.admin.controller;

import com.admin.service.SysLogService;
import com.fegin.bean.admin.SysLog;
import com.fegin.bean.common.layuiBean.ResultPage;
import com.fegin.bean.common.layuiBean.VoPage;
import com.util.Respons.ResponseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Map;

/**
 * @author 张子艺
 * @packge com.controller.admin
 * @data 2019-01-11 14:31
 * @project Currency
 */
@Controller
@RequestMapping("/admin/log")
public class SysLogController {
    @Autowired
    SysLogService sysLogService;
    /**
     * 日志管理主页面
     * @return
     */
    @RequestMapping(value = "/main.html", method = RequestMethod.GET)
    public String main() {
        return "system/log";
    }


    /**
     * 日志表格查询
     * @param voPage
     * @return
     */
    @RequestMapping(value = "/findLog" )
    @ResponseBody
    public ResultPage<SysLog> findLog(@RequestBody VoPage voPage) {
      //  Mybatis plus分页插件查询
  /*      Page<SysLog> sysLogPage=new Page<>();
        sysLogPage.setCurrent(1);
        sysLogPage.setSize(2);
          Page<SysLog> logPage=sysLogService.selectPage(sysLogPage);*/
        return  sysLogService.findLogByPage(voPage);
    }


    /**
     * 日志新增
     * @return
     */
    @RequestMapping(value = "/insert" )
    @ResponseBody
    public Map<String, Object> insert(@RequestBody SysLog sysLog) {
     if(sysLogService.save(sysLog)){
         return ResponseUtil.getSuccessMap();
     }
        return ResponseUtil.getExceptionMap();
    }





}
